# Contributor: goodspb <goodspb.luo@gmail.com>
# Maintainer: Adriaan Groenenboom <agboom@pm.me>
pkgname=php7-pdlib
_pkgreal=pdlib
pkgver=1.0
pkgrel=1
pkgdesc="PHP extension for Dlib"
url="https://github.com/goodspb/pdlib"
arch="all !ppc64le !mips !mips64" # build fails https://github.com/goodspb/pdlib/issues/19
license="MIT"
depends="php7-common dlib"
makedepends="php7-dev pkgconf php7-bz2"
source="$pkgname-$pkgver.tar.gz::https://github.com/goodspb/$_pkgreal/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgreal-$pkgver"

build() {
	phpize7
	./configure --prefix=/usr --with-php-config=php-config7
	make
}

check() {
	# Remove broken tests https://github.com/goodspb/pdlib/issues/14
	rm \
		tests/chinese_whispers_wrong_arg_type_error.phpt \
		tests/cnn_face_detection_ctor_error.phpt \
		tests/face_landmark_detection_ctor_error.phpt \
		tests/face_recognition_ctor_error.phpt \
		tests/integration_face_recognition.phpt   # Downloads huge images

	# Tests require bz2 extension which is not bundled
	sed -i 's#PHP_TEST_SHARED_EXTENSIONS =  `#PHP_TEST_SHARED_EXTENSIONS = -d extension=/usr/lib/php7/modules/bz2.so `#' Makefile
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	install -d "$pkgdir"/etc/php7/conf.d
	echo "extension=$_pkgreal.so" > "$pkgdir"/etc/php7/conf.d/$_pkgreal.ini
}

sha512sums="1ff8c3b55d69321e1b1bcec6f8f41240138adfe0298269f857f5ee9655d783324f16a371f61b8eb97638d7014a724faa4c80e81b67b51c34e6203a309abeacae  php7-pdlib-1.0.tar.gz"
